Pruning disk blocks of a clustered table in a relational database management system

ABSTRACT

Techniques are provided for generating a “dimensional zonemap” that allows a database server to avoid scanning disk blocks of a fact table based on filter predicates in a query that qualify one or more dimension tables. The zonemap divides the fact table into sets of contiguous disk blocks referred to as “zones”. For each zone, a minimum value and a maximum value for each of one or more “zoned” columns of the dimension tables is determined and maintained in the zonemap. For a query that contains a filter predicate on a zoned column, the predicate value can be compared to the minimum value and maximum value maintained for a zone for that zoned column to determine whether a scan of the disk blocks of the zone can be skipped.

TECHNICAL FIELD

The present invention relates to relational database management systemsand, more specifically, to techniques for pruning disk blocks of aclustered table in a relational database management system.

BACKGROUND

The approaches described in this section are approaches that could bepursued, but not necessarily approaches that have been previouslyconceived or pursued. Therefore, unless otherwise indicated, it shouldnot be assumed that any of the approaches described in this sectionqualify as prior art merely by virtue of their inclusion in thissection.

In the context of database systems, a “dimension” is a list of valuesthat provide categories for data. A dimension acts as an index foridentifying values of a variable. For example, if sales data has aseparate sales figure for each month, then the data has a MONTHdimension. That is, the data is organized by month. A dimension issimilar to a key in a relational database. Data that is organized by twoor more dimensions is referred to as “multidimensional data”.

Any item of data within a multidimensional variable can be uniquely andcompletely selected by specifying one member for each of the variable'sdimensions. For example, if a sales variable is dimensioned by MONTH,PRODUCT, and MARKET, specifying “January” for the MONTH dimension,“Stereos” for the PRODUCT dimension, and “Eastern Region” for the MARKETdimension uniquely specifies a single value for the variable. Thus,dimensions offer a concise and intuitive way of organizing and selectingdata for retrieval, updating, and performing calculations.

Multidimensional data may be stored in relational database systems. Whenmultidimensional data is stored in a relational database system,applications access the data by submitting commands that conform to thedatabase language supported by the relational database system, the mostcommon of which is the Structured Query Language (SQL).

Relational database systems store data in the form of related tables,where each table has one or more columns and zero or more rows. Theconventional mechanism for storing multidimensional data in a relationaldatabase system is to store the data in tables arranged in what isreferred to as a star schema. In relational database systems, a starschema is distinguished by the presence of one or more relatively largetables and several relatively smaller tables. Rather than duplicatingthe information contained in the smaller tables, the larger tables referto rows in the smaller tables. Within a star schema, the larger tablesare referred to as “fact tables”, while the smaller tables are referredto as “dimension tables”. FIG. 1 illustrates an exemplary star schemawith two dimensions.

Referring to FIG. 1, it illustrates a database 100 that includes tables102, 104, and 106. Table 102 is named “stores” and contains informationabout each of the stores in which sales may occur. Each row in thestores table 102 contains a unique store-id and information and theparticular store that corresponds to the store-id. Table 104 is named“products” and contains information about each type of product that maybe sold in any of the stores. Each row in the products table 104contains a unique product-id and information about the particularproduct.

Table 106 is named “sales” and contains information about each sale ineach of the stores represented in the stores table 102. Each row in thesales table 106 includes a dollar amount, a store-id to indicate thestore at which the sale was made, a product-id to indicate the productsold in the sale, and the date of the sale. Typically, the number ofsales will be vastly greater than both the number of stores at which thesales are made and the number of products carried by the stores.Detailed information about the store and product involved in a sale doesnot have to be stored in the rows of the sales table 106 because suchdetailed information is available in the stores table 102 and theproducts table 104, respectively. Instead, the rows of table 106 containvalues (store-ids and product-ids) that reference information stored inthe other tables 102 and 104. Therefore, tables 102, 104, and 106constitute a star schema in which table 106 is a fact table and tables102 and 104 are dimension tables.

The data stored in fact table 106 only has two dimensions, and facttable 106 has two columns (STORE-ID and PRODUCT-ID) dedicated to storingforeign key values for those dimensions. Typically, a fact tablededicates one column for storing foreign key values for each of thedimensions associated with the multidimensional data stored in the facttable. By storing foreign key values in the fact table that refer torows in the dimension tables, the rows of the fact table can be kept toa relatively small size and the number of columns of the fact table canbe kept to a relatively small number. For example, instead of the salestable 106 containing the values in the MANAGER, CITY, and STATE columnsof the stores table 102 and the values in the SOURCE, PARTS, and COSTcolumns of the products table 104, the sales table 106 contains foreignkey values in two columns, one column referring to rows in the storestable 102 and the other column referring to rows in the products table104. The number of rows in a typical fact table can be billions or more.In contrast, the number of rows in a dimension table is typically muchlower (e.g., in the tens, hundreds, or thousands). Accordingly, atypical star schema is constructed to minimize the amount of data storedin each row of the fact table.

A query on multidimensional data may retrieve aggregates of fact table“measures” constrained by “dimension key values”. For example, a queryissued against the tables illustrated in FIG. 1 may retrieve the sum ofall “amount” values from sales table 106 that occurred in San Jose. Inthis example, execution of the query involves joining rows from thesales table 106 with the rows, from stores table 102, where the “city”column has the value “San Jose”.

This type of query is also referred to as a “star query”. The “measures”of a fact table are the values in columns of the fact table that do notcontain foreign key values. For example, the values in the AMOUNT andDATE columns of the sales tables 106 are the sale amount measures andthe date of sale measures, respectively. The “dimension key values” arethe values associated with a particular dimension. For example, thedimension key values for a “region” dimension may be “Northern Region”,“Southern Region”, “Eastern Region” and “Western Region”.

In a star schema, the dimension key values of a dimension are typicallystored in the dimension key column of the dimension table associatedwith the dimension. For example, the dimension key values of storestable 102 are stored in the “store-id” column of stores table 102.Similarly, the dimension key values of products table 104 are stored inthe “product-id” column of products table 104.

Star queries often contain filter predicates on the dimension tables.The following is an example of a star query that joins the sales facttable 106 with qualified stores 102 and products 104 dimension tables.The stores dimension table 102 is qualified by the filter predicatest.state=“CA” and the products dimension table 104 is qualified by thefilter predicate pr.cost >10. The example star query requests the sum ofsale amounts, by store city and product source, for the state ofCalifornia, for products that cost more than $10.

SELECT st.city, pr.source, SUM(sa.amount) FROM sales sa, stores st,products pr WHERE sa.store-id = st.store-id AND sa.product-id =pr.product-id AND st.state = “CA” AND pr.cost > 10 GROUP BY st.city,pr.source

One approach for improving performance of a star query in a relationaldatabase management system is to organize related data in the fact tablein contiguous disk blocks on disk. A “disk block” is a logical unit ofdata storage used by a relational database management system for storingdatabase data. A disk block has a block size (e.g., 4 KB) and mayencompass one or more underlying file system or operating system blocks.Among other information, a disk block may include the data of one ormore rows of a table or tables, or the data of a row may span multipledisk blocks.

In the context of storing multidimensional data in relational databasemanagement systems, the organization of related fact table data incontiguous disk blocks on disk is referred to as “clustering”.Clustering can improve performance of star queries in relationaldatabase management systems by facilitating compression, indexing, andInput/Output (I/O) pruning. In the context of answering a star query ina relational database management system, I/O pruning refers to avoidingdisk scans of certain disk blocks of the fact table that are known notto contain data relevant to the star query when scanning the fact tablefor data that is relative to the star query. Recent technologicalimprovements in data storage devices have improved database access tothe point that database systems sometimes perform table scans in lieu ofindexed table access when executing a query, even where indexes areavailable. Consequently, techniques for clustering to facilitate I/Opruning have recently gained considerable attention in the industry.

There are a variety of different approaches to clustering a fact tablein a relational database management system. In one approach, rows of thefact table are stored on-disk in a linear order based on the values inone or more columns of the rows of the fact table. For example, rows ofthe fact table can first be ordered by a query with an ORDER BY clausespecifying one or more columns of the fact table, and then storing therows in the sorted order on-disk in one or more contiguous disk blocks.In another approach, a fact table is clustered along multiple dimensionsbased on values in columns of the fact table according to a space filingcurve such as a Z-order curve or a Hilbert space filing curve. In bothapproaches, the fact table is clustered based only on the columns of thefact table. These approaches facilitate I/O pruning when the fact tableis clustered based on the columns of the fact table when the star querycontains filter predicates on those columns.

Unfortunately, the performance bottleneck of executing a star query inrelational database management systems is typically the join between therelatively large fact table and the dimension tables, referred to as a“star join”. The dimension tables are often qualified in a star query byone or more, often highly selective, filter predicates on the dimensiontables. In many cases, a star query does not contain any filterpredicates on the columns of the fact table. For example, the examplestar query above contains the filter predicate st.state=“CA” thatqualifies the stores dimension table 102, and contains the filterpredicate pr.cost >10 that qualifies the products dimension table 104,but does not contain any filter predicate on the AMOUNT column or theDATE column of the sales table 106.

A relational database management system that clusters a fact table basedonly on the columns of the fact table may perform wasteful disk scanningof the fact table when performing a star join. The disk scan may bewasteful because, in the absence of any filter on the fact tablecolumns, the clustering of the fact table does not help, and all diskblocks of the fact table may need to be scanned. Specifically, even ifthe sales table 106 is clustered based on “date”, the rows of the salestable 106 that join with the rows of stores table 102 wherest.state=“CA”, and with the rows of products table 104 wherepr.cost >10, may be randomly distributed within the sales table 106.

The approaches described in this section are approaches that could bepursued, but not necessarily approaches that have been previouslyconceived or pursued. Therefore, unless otherwise indicated, it shouldnot be assumed that any of the approaches described in this sectionqualify as prior art merely by virtue of their inclusion in thissection.

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings:

FIG. 1 is a block diagram that illustrates an example star schema;

FIG. 2 is a block diagram of database server components for processing aDDL statement with a clustering clause, according to an embodiment ofthe present invention;

FIG. 3 illustrates an example lineitem table;

FIG. 4 is a block diagram of a portion of a disk containing disk blocks;

FIG. 5 illustrates an example zonemap table and contains the blockdiagram of FIG. 4 with disk blocks grouped into zones, according to anembodiment of the present invention;

FIG. 6 illustrates the table structure of a possible dimensionalzonemap, according to an embodiment of the present invention;

FIG. 7 is a flowchart of a disk scan performed by a database server,according to an embodiment of the present invention;

FIG. 8 illustrates the table structure of a possible dimensionalzonemap, according to an embodiment of the present invention;

FIG. 9 is a block diagram illustrating a computer system on whichembodiments of the invention may be implemented.

DETAILED DESCRIPTION

A method and apparatus for pruning disk blocks of a clustered table in arelational database management system is described. In the followingdescription, for the purposes of explanation, numerous specific detailsare set forth in order to provide a thorough understanding of thepresent invention. It will be apparent, however, that the presentinvention may be practiced without these specific details. In otherinstances, well-known structures and devices are shown in block diagramform in order to avoid unnecessarily obscuring the present invention.

General Overview

Techniques are provided that address the problems associated with priorapproaches for clustering a fact table in a relational databasemanagement system. According to one aspect of the invention, a databaseserver clusters a fact table in a database based on values from one ormore columns of one or more dimension tables. More specifically, rowsare stored in the fact table in a sorted order and the order in whichthe rows are sorted is based on values in one or more columns of one ormore of the dimension tables. A user specifies the columns of thedimension tables on which the sorted order is based in “clusteringcriteria”. The database server uses the clustering criteria toautomatically store the rows in the fact table in the sorted order inresponse to certain user-initiated database operations on thefact-table.

For purposes of explanation, a column of the dimension tables specifiedin the clustering criteria and on which the sorted order is based isreferred to herein as a “clustering dimension column”. A dimension tableof which a clustering dimension column is specified in the clusteringcriteria is referred to herein as a “clustering dimension table”.

Various techniques are provided herein for storing rows in a fact tablein a sorted order based on clustering dimension columns specified inclustering criteria. In general, the process involves the databaseserver generating a “clustering” query that (a) selects a set of“source” fact table rows, (b) performs a join between the source facttable rows and the clustering dimension tables to produce a set ofjoined rows in which each row in the set of joined rows corresponds toat most one of the source fact table rows, (c) sorts the joined rowsusing values of the clustering dimension columns as sort keys, and (d)stores the source fact table rows in the fact table in the sorted order.Significantly, the values from the clustering dimension columns thatwere used as a basis for sorting the fact table rows are not stored inthe fact table.

As explained in greater detail hereinafter, the source fact table rowsmay be selected from the fact table or from other sources (e.g., from anexternal table). The joined rows may be sorted in a linear order or inan interleaved order. An interleaved ordering may be based on aspace-filling curve such as a Z-order space-filling curve or a Hilbertspace-filling curve. Sorting the joined rows using values of theclustering dimension columns as sort keys causes source fact table rowsthat are conceptually related to each other to be stored physically neareach other within the fact table. Because the conceptually related facttable rows are stored physically near each other based on values of theclustering dimension columns, I/O pruning during a disk scan of the facttable based on filter predicates on the clustering dimension columns ispossible.

According to another aspect of the invention, an access structure isgenerated in the database that allows the database server to avoidscanning disk blocks of a fact table based on filter predicates in aquery that qualify one or more dimension tables. This access structureis referred to hereinafter as a “dimensional zonemap”. Generally, thedimensional zonemap generation process involves dividing the fact tableinto sets of contiguous disk blocks referred to hereinafter as “zones”.For each zone, a minimum value and a maximum value for each of one ormore “zoned” columns of the dimension tables is determined andmaintained in the zonemap. For a query that contains a filter predicateon a zoned column, the predicate value can be compared to the minimumvalue and maximum value, for that zoned column, maintained for a zone todetermine whether the zone contains any fact table rows that satisfy thefilter predicate. Because the minimum and maximum values maintained forthe zones are determined based on values of columns of the dimensiontables, I/O pruning is possible during a disk scan of the fact tablebased on filter predicates that qualify the dimension columns.

Clustering Criteria

As mentioned above, star queries often qualify dimension tables withfilter predicates on the dimension tables. For example, in the followingexample star query, the countries dimension table is qualified with twofilter predicates, one on the region column of the countries dimensiontable and the other on the subregion column of the countries dimensiontable.

SELECT countries.region, countries.subregion, countries.name,sum(sales.amount_sold) FROM sales JOIN countries ON sales.country_id =countries.country_id WHERE countries.region = ‘Europe’ ANDcountries.subregion = ‘Eastern Europe’ GROUP BY countries.region,countries.subregion, countries.name

Also as mentioned previously, the performance bottleneck executing astar query is likely to be the join between the fact table and thedimension tables. Where the filter predicates in a star query qualifythe dimension tables, it would be beneficial to reduce, through I/Opruning, the number of rows of the fact table that are involved in thestar join. To facilitate such I/O pruning, a user causes conceptuallyrelated fact table rows to be physically stored near each other withinthe fact table, where “conceptually related” can be based on values inone or more columns of one or more dimension tables.

As well as facilitating I/O pruning, physically storing conceptuallyrelated fact table rows near each other within the fact table alsofacilitates data compression of the fact table and indexing of the facttable. Storing conceptually related fact table rows near each otherwithin the fact table may result in the values in the one or morecolumns of the fact table rows to be similar to each other therebyresulting in better compression of such column values. For example, ifthe values in a column of the fact table rows are stored on disk in asorted order, then a run length encoding compression algorithm can behighly effective in compressing the data in such a column. Creation ofan index on one or more clustering columns of the fact table facilitatesimproved performance of accessing the fact table data via such an index.The reason for improved accessibility of the fact table data is due tothe physical proximity on disk of the fact table rows having the sameindex key values. For example, because of the clustering of the facttable, if all fact rows with a particular index key value are storedtogether in a disk block (or a set of disk blocks), then the retrievalof such fact rows via the index can incur a reduced amount of disk I/O.

In certain embodiments described herein, techniques are providing forclustering a fact table based on values in one or more columns of one ormore dimension tables. However, it should be appreciated that thetechniques may also be applied to cluster a fact table based on valuesin one or more columns of one or more dimension tables and values in oneor more columns of the fact table or to cluster a fact table based onlyon values in one or more columns of the fact table.

DDL Interface for Clustering Criteria

According to one aspect of the present invention, a data definitionlanguage (DDL) interface is provided by which a user can specifyclustering criteria to associate with a fact table. The clusteringcriteria may be stored in the database as metadata of the fact table. Asdescribed in greater detail below, the clustering criteria are read fromthe database when generating a clustering query to cluster the facttable.

In one embodiment, an additional “clustering” clause is added to a DDLstatement that defines the fact table. Such a DDL statement may be usedin the context of creating the fact table, altering its definition, orany other DDL action that defines, changes, or modifies the columns orconstraints of the fact table. Thus, the user may conveniently associateclustering criteria with a fact table when defining the fact table. Forexample, the following exemplary DDL statement, to create the salestable, includes a clustering clause designated by the keyword“CLUSTERING”:

CREATE TABLE sales (      countries_id number not null, ....     amount_sold number(10,2) ) CLUSTERING    sales JOIN countries ON(sales.country_id =    countries.country_id)    BY LINEAR ORDER(countries.region, countries.subregion,    countries.name)

In this description, examples of user-specified clustering criteria areprovided in the form of example SQL statements. It should be understoodthat the syntax of the example SQL statements is merely exemplary. Thepresent invention is not limited to the syntax of the examples and othersyntaxes for conveying the same clustering criteria semantics may beused.

Clustering Criteria Clustering Dimension Columns and Join Criteria

The clustering criteria are used to specify a number of differentclustering options for clustering a fact table based on values in one ormore dimension tables. In one embodiment, the clustering criteriaspecify one or more clustering dimension columns and join criteria. Theone or more clustering dimension columns are the columns of thedimension tables by which the user wishes to sort rows of the facttable, either by a linear ordering or by an interleaved ordering. Theclustering dimension columns are typically the columns of the dimensiontables that the user expects star queries to contain filter predicateson.

In the examples herein, the clustering dimension columns are specifiedin a sub-clause of the clustering clause as parameters to a sortingmethod directive. Sorting method directives are described in greaterdetail below. For example, in the clustering clause above, theclustering dimension columns countries.region, countries.subregion, andcountries.name are specified as parameters to the sorting methoddirective BY LINEAR ORDER. However, other manners of specifying thecolumns of the dimension tables by which the user wishes to sort rows ofthe fact table may be used and the present invention is not limited tothe manners of the examples. For example, clustering dimension columnsmay be specified by the user in clustering criteria without any sortingmethod directive where a default sorting method directive is implied.

The join criteria specifies foreign key columns of the fact table andunique key columns in the clustering dimension tables by which the userwishes to join the fact table with the clustering dimension tables. Forexample, the clustering clause in the above example DDL statementspecifies the clustering dimension columns countries.region,countries.subregion, and countries.name and specifies join criteria forequi-joining the sales fact table with the countries clusteringdimension table using the country_id foreign key column of the salestable and the country_id unique key column of the countries table. Anequi-join is a specific type of join in which only equality comparisonoperators (e.g., “=”) are used in the join predicates and rangecomparison operator (e.g., “>”, “<”) are not used. The join criteria areused to formulate the clustering query as described in greater detailbelow. Because only unique key columns in the clustering dimensiontables are specified in the join criteria, a row from the fact tablewill be joined by the clustering query with at most one row from each ofthe clustering dimension tables and a row from the fact table willcorrespond to at most one row in the set of joined rows formed by theclustering query.

The clustering criteria can be used to specify clustering options forclustering a fact table based on more than one dimension, where eachdimension corresponds to a different dimension table. In this case, joincriteria are provided by the user for joining the fact table with eachof the different dimension tables as in the following example clusteringclause which specifies the clustering dimension columnspromotions.subcategory and products.subcategory and also specifies joincriteria for joining the sales fact table with the promotions clusteringdimension table using the promo_id foreign key column of the sales tableand the promo_id unique key column of the promotions table. Theclustering clause also specifies join criteria for joining the salesfact table with the products clustering dimension table using theprod_id foreign key column of the sales table and the prod_id unique keycolumn of the products table.

CREATE TABLE sales (    prod_id not null number.    promo_id not nullnumber, ....    amount_sold number(10,2) ) CLUSTERING    sales JOINpromotions ON (sales.promo_id =    promotions.promo_id)    JOIN productsON (sales.prod_id = products.prod_id)    BY INTERLEAVED ORDER(promotions.subcategory,    products.subcategory)

Clustering Criteria Sorting Method

According to an embodiment of the present invention, the clusteringcriteria specify the type of sorting to perform on the set of joinedrows formed by the clustering query. The type of sorting performed bythe clustering query determines how a set of source fact table rowsselected by the clustering query is clustered within the fact table. Howa set of source fact table rows are clustered within the fact tabledetermines the I/O efficiencies that can be realized through I/O pruningbased on filter predicates in a query. In general, the type of sortingis one of two general types: linear or interleaved. In both cases, thesorting may be based on the clustering dimension columns.

Clustering Criteria Linear Sorting Method

With linear ordering, the joined rows formed by the clustering query aresorted in ascending or descending order based on the values of theclustering dimension columns in the joined rows. If more than oneclustering dimension column is specified in the clustering criteria,then the sequence of the multiple clustering dimension columns asspecified by the user in the clustering criteria defines theorganization of the sorted joined rows. That is, the joined rows arefirst sorted by the first clustering dimension column in the sequence,then that set of ordered joined rows is sorted by the second clusteringdimension columns in the sequence, and so on. The source fact table rowsare then stored within the fact table in the sorted linear order incontiguous disk blocks.

A linear sorting may be designated in a clustering clause in which thesequence of clustering dimension columns is specified as a parameter ofthe linear sorting ordering designation. As an example of a clusteringclause specifying a linear sort order, the clustering clause in thefollowing DDL statement to create a sales table specifies that the setof joined rows formed by the clustering query are to be sorted firstbased on the values in the countries.region column of the joined rows,then that set of ordered joined rows is to be sorted based on the valuesin the countries.subregion column, and then that set of ordered joinedrows is to be sorted by the values in the countries.name column.

CREATE TABLE sales (      countries_id number not null, ....     amount_sold number(10,2) ) CLUSTERING    sales JOIN countries ON(sales.country_id =    countries.country_id)    BY LINEAR ORDER(countries.region, countries.subregion,    countries.name)

With a linear sort order, the greatest I/O pruning benefits can berealized when a star query contains filter predicates on a prefix of thesequence of clustering dimension columns specified in the clusteringcriteria, for example, if a star query contains a filter predicate onthe countries.region column. However, limited or no I/O pruning benefitscan be realized with a linear ordering when a star query contains filterpredicates only on a suffix of the clustering dimension columns or doesnot contain any filter predicates on the clustering dimension columns.Consequently, a linear sort order will typically be used only when mostof the star queries contain filter predicates on a prefix of thesequence of clustering dimension columns or when a benefit of clusteringother than I/O pruning, such as data compression (e.g., throughrun-length encoding), is desired. If greater I/O pruning flexibility isneeded, the user can select an interleaved sorting method in theclustering criteria.

Clustering Criteria Interleaved Sorting Method

With an interleaved sorting method, I/O pruning on the fact table can beperformed on a filter predicate in a query independently of other filterpredicates in the query. In particular, I/O pruning can be performed ona filter predicate on a clustering dimension column in a queryregardless of the position of that clustering dimension column in theclustering criteria. For example, with the following clustering criteriathat specifies an interleaved sort ordering, I/O pruning on the salestable can be performed on one or more of the promotions.subcategory andthe products.subcategory columns independently of each other.

CREATE TABLE sales (   prod_id not null number.   promo_id not nullnumber, ....   amount_sold number(10,2) ) CLUSTERING   sales JOINpromotions ON (sales.promo_id =   promotions.promo_id)   JOIN productsON (sales.prod_id = products.prod_id) BY INTERLEAVED ORDER(promotions.subcategory, products.subcategory)

A variety of different approaches may be used to achieve an interleavedordering of rows stored in the fact table. In general, the approachesinvolve use of a space-filling curve such as a Z-order curve or aHilbert space-filling curve that have the property that points which areclose to each other in a finite n-dimensional space are mapped tosingle-dimensional values which are also in proximity to each other.Conceptually, the n-dimensional space is divided into an n-dimensional“cube” of cells. By convention, the division of the n-dimensional spaceis referred to as “cube” even though the number of dimensions n can betwo or more than three. Each cell of the cube is assigned a range ofvalues, one range of values for each of the n-dimensions. The number ofdimensions n equals the number of clustering dimension columns specifiedin the clustering criteria.

For a set of source fact table rows to be stored within a fact table inan interleaved order, each source fact table row in the set is mapped toa cell in the cube based on the values of the clustering dimensioncolumns in the joined row formed by the clustering query correspondingto the source fact table row and the ranges of values assigned to thecells. More than one source fact table row may be mapped to a cell inthe cube. Some cells in the cube may not have any source fact table rowsmapped to them. The space-filing curve imposes a linear ordering thecells. Source fact table rows assigned to the cells are stored withinthe fact table in the linear order imposed by the space-filing curvewith the effect that conceptually related rows that are close to eachother in the n-dimensional cube are also close to each other within thefact table.

In the above example, a default space-filing curve is implied by thedirective BY INTERLEAVED ORDER. The default space-filing curve can beany one of a number of known space-filing curves such as a Z-orderspace-filing curve or a Hilbert space-filing curve. Alternatively, thespecific space-filing curve to use may be explicitly specified in theclustering criteria. For example, instead of BY INTERLEAVED ORDER, BYHILBERT ORDER or BY Z ORDER may be specified instead.

Further information on the use of Z-Order space-filing curves formultidimensional clustering may be found in Morton, G. M, A ComputerOriented Geodetic Data Base and A New Technique in File Sequencing,International Business Machines Company, 1966. Further information onthe use of Hilbert space-filing curves for multidimensional clusteringmay be found in Chapter 14 of Warren, Henry S., Hacker's Delight,Addison-Wesley Professional, 2003.

Clustering Criteria When to Cluster

According to one embodiment of the present invention, clusteringcriteria specifies when clustering of a fact table is to be performed.In particular, the user may specify what actions trigger clustering ofthe fact table. In general, there are two types of actions that cantrigger clustering of the fact table. One type is action is loading datainto the fact table. With this type, the data added to the fact table isclustered according to clustering criteria associated with the facttable. The other type of action is moving data from one storage locationof the fact table to another storage location. The moved data isclustered according to clustering criteria associated with the facttable.

An example of the data loading type of action that can triggerclustering of the fact table is the submission of a data modelinglanguage (DML) statement to add rows to the fact table. The INSERTstatement is an example of a DML statement for adding rows to a table.For example, clustering a sales fact table may be triggered uponsubmission of the following INSERT statement:

INSERT INTO sales SELECT promo_id, prod_id, . . . amount_sold FROMsales_external

In response to receiving the above INSERT statement, the rows selectedfrom the sales_external table by the SELECT sub-clause will be thesource fact table rows selected and stored within the sales fact tablein a sorted order by the automatically generated clustering query.

An example of the data movement type of action that can triggerclustering of the fact table is partition maintenance operations on thefact table. Very generally, a partition is strict subset of all rows ofa table that share the same column and constraint definitions with theother rows of the table but can have different physical attributes fromthe other rows. For example, two partitions of a table can be stored onseparate storage devices. Partition maintenance operations that cantrigger clustering of a fact table include moving a partition of thefact table to from one data storage location to another. When moving apartition of a fact table triggers clustering, the source fact tablerows are all of the rows of the partition to be moved.

Another example of the data movement type of action that can triggerclustering of the fact table is an on-line redefinition of the facttable. On-line redefinition of a “source” table generally involvesdefining and creating an interim table and copying the data of thesource table into the interim table while allowing the source table tobe accessible to read and write operations during the copy. The interimtable may be defined with a new structure relative to the source table.For example, the interim table may remove columns, add columns, orrename columns from the source table. Further, data copied from thesource table to the interim table may be transformed. Updates to thesource table made while the data is being copied to the interim tableare stored in a log. During the copy, the data in the log may besynchronized with the interim table. Once the copying is finished, thesource table and interim table are briefly locked for exclusive accessto synchronize any remaining changes in the log with the interim tableand to finalize the redefinition. After the redefinition is finalized,the interim table is the “new” source table and the “old” source tablemay be dropped.

For purposes of clustering during on-line redefinition of a fact table,the source fact table rows selected by the clustering query are the rowsof the source table. The clustering criteria associated with the sourcetable are used to sort the rows of the source table when copying thesource table to the interim table. The sorted rows of the source tableare stored within the interim table in the sorted order. The sorted rowsof the source table may also undergo any data transformations defined bythe on-line redefinition. Rows stored in the interim table may also beclustered when the source table log is synchronized with the interimtable during copying. As when copying rows of the source table to theinterim table, when rows in the source table log are synchronized withthe interim table, the clustering criteria associated with the sourcetable is used to cluster the rows of the source table log within theinterim table.

When clustering occurs on a fact table may be specified by a user in aclustering clause. For example, the clustering clause in the followingDDL statement to create a sales table specified that clustering shouldoccur on data loading actions (e.g., when rows are inserted into thesales table) and on data movement actions (e.g., when the sales table ispartitioned or when the sales table is redefined on-line).

CREATE TABLE sales (   prod_id not null number.   promo_id not nullnumber, ....   amount_sold number(10,2) ) CLUSTERING   sales JOINpromotions ON (sales.promo_id =   promotions.promo_id)   sales JOINproducts ON (sales.prod_id = products.prod_id)   BY INTERLEAVED ORDER(promotions.subcategory,   products.subcategory)   YES ON LOAD YES ONDATA MOVEMENT

Here, the keyword sequence “YES ON LOAD” is used to indicate thatclustering of the sales table should occur on data loading actions. Thekeyword sequence “YES ON DATA MOVEMENT” is used to indicate thatclustering of the sales table should also occur on data movementactions. If, by default, clustering is performed on data loading actionsand data movement actions then the keywords sequences “NO ON LOAD”and/or “NO ON DATA MOVEMENT” can be used to selectively disable defaultclustering options. Of course, other syntaxes may be used to convey thesame semantics.

Processing a Clustering Clause in a DDL Statement

As mentioned above, a DDL statement to define a fact table may contain aclustering clause specifying clustering criteria. For example, thefollowing DDL statement contains a clustering clause to add clusteringcriteria to a sales table.

ALTER TABLE sales ADD CLUSTERING   sales JOIN promotions ON(sales.promo_id =   promotions.promo_id)   JOIN products ON(sales.prod_id = products.prod_id)   BY INTERLEAVED ORDER(promotions.subcategory,   products.subcategory)   YES ON LOAD YES ONDATA MOVEMENT

Components of a database server for processing a clustering clause in aDDL statement are illustrated in FIG. 2. Initially, a DDL statement 201defining a fact table and with a clustering clause is received. Thestatement 201 may be received from a variety of different sources. Forexample, the statement 201 may be received from a user through a commandline or graphical user interface. Alternatively, the statement 201 maybe received from another computing process, for example, a remotecomputing process that sends the statement 201 over a network to thedatabase server. These are just some examples of possible sources of thestatement 201 and the present invention is not limited to any particularsource from which the statement 201 can be received.

Upon receiving the statement 201, the statement 201 is provided to aparsing routine 202. The parsing routine 202 parses the statement 201 toproduce a table definition control structure 203. Among other possibleinformation in the table definition control structure 203, the structure203 specifies one or more elements of the clustering clause in the DDLstatement 201. These elements of the structure 203 may include anyclustering directives such as whether clustering of the fact table is tooccur on data loading actions, on data movement actions, or on both dataloading and data movement actions. The elements of the structure 203 mayalso include the one or more clustering dimension columns, the one ormore clustering dimension tables, and the join criteria specified in theclustering clause.

A table definition execution driver 204 uses the structure 203 tovalidate the clustering clause and to create table metadata in thedatabase for the defined table representing the clustering criteria. Forvalidation, the driver 204 validates the existence of the clusteringdimension columns and the clustering dimension tables. If one of theclustering dimension tables or one of the clustering dimension columnsdoes not exist in the database, then the driver 204 may reject thestatement 201 with an error. The driver 204 also validates the joincriteria. The validation of the join criteria includes performingforeign key validation on the foreign key columns of the fact table thatrefer to the clustering dimension tables. At least part of the foreignkey validation includes the driver 204 verifying that all join columnsof the clustering dimension tables referred to in the join criteria haveunique key constraints and that the joins specified by the join criteriaare all equi-joins. This validation is done to ensure that, when theclustering query joins the source fact table rows with the clusteringdimension tables based on the join criteria, no source fact table rowsare duplicated in the set of joined rows. If the driver 204 determinesthat one of the join columns of the clustering dimension columns doesnot have a unique key constraint, the driver 204 may reject thestatement 201 with an error.

Assuming there are no errors with the statement 201, once validated, thedriver 204 stores metadata in the database representing the clusteringcriteria. For example, the driver 204 may store the metadata in datadictionary tables of the database or in another repository ofinformation about database data.

A Function for Interleaved Sorting

According to one embodiment of the present invention, a function isprovided for use within clustering queries to store rows within a facttable in an interleaved order. The function accepts between one to fourarguments (expressions) and returns a raw string as output.

raw_string=ORA_CLUSTERING(expr1[, expr2, expr3, expr4])

The function ORA_CLUSTERING treats the arguments as binary data andevaluates a space-filing curve on the binary arguments (e.g., a Hilbertspace-filing curve or a Z-order function). The evaluation is based on abit mixing of the binary representations of the arguments. Inparticular, the first bit is taken from each of the arguments, then thesecond bit is taken from each of the arguments, then the third bit istaken from each of the arguments, and so on, to create a bit string as aresult. So that consistent weight is given to each argument, thearguments may be padded to their maximum lengths with a padding value(e.g., byte value 0x00). The size of the returned raw string will thenbe the sum of the lengths of the arguments as padded. Arguments to thefunction may be truncated to a maximum allowed number of bytes (e.g.,1000) for efficiency.

Clustering a Fact Table on Load

As mentioned previously, clustering criteria associated with a facttable may specify that clustering is to be performed on rows loaded intothe fact table. A typical way rows are loaded into a table is with anINSERT DML statement containing a SELECT sub-query. For example, thefollowing INSERT statement appends rows to a sales table based on rowsselected from a sales_external table.

INSERT /*+ APPEND */ INTO sales SELECT promo_id, prod_id, ...amount_sold FROM sales_external.

According to one embodiment of the present invention, a DML statement toload rows into a table associated with clustering criteria isautomatically converted to a clustering query. The clustering query isexecuted instead of the original DML statement to load the rows into thetable associated with the clustering criteria in a sorted order. Theclustering query is generated to include the select sub-query of theoriginal DML statement that selects the source fact table rows, the joincriteria of the clustering criteria, and an ORDER BY clause to sort thesource fact table rows by the clustering dimension columns and in thesort order designated by the clustering criteria (e.g., linear orinterleaved sort order). The join criteria may be converted as necessaryso that the joins between the fact table and the dimension tables areleft outer joins, with the fact table being the left hand table, so thatnone of the source fact table rows are missing from the set of joinedrows formed by the clustering query.

As an example, consider the clustering criteria specified in thefollowing DDL statement to create a sales table.

CREATE TABLE sales (   prod_id not null number,   promo_id not nullnumber, ...   amount_sold number (10, 2) ) CLUSTERING   JOIN promotionsON (sales.promo_id = promotions.promo_id)   JOIN products ON(sales.prod_id = products.prod_id)   BY LINEAR ORDER(promotions.subcategory,   products.subcategory)   YES ON LOAD

Here, source fact table rows are to be clustered in the sales fact tablea linear order based on the subcategory column of the promotionsdimension table and the subcategory column of the products dimensiontable.

Now assume the following DML statement to load rows into the sales facttable is submitted to the database server.

INSERT INTO sales SELECT promo_id, prod_id, . . . amount_sold FROM salesexternal

Upon receiving this DML statement, the database server may automaticallyconvert the DML statement into the following clustering query.

INSERT INTO sales SELECT promo_id, prod_id, ... amount_sold FROMsales_external   LEFT OUTER JOIN promotions ON (sales.promo_id =  promotions.promo_id)   LEFT OUTER JOIN products ON (sales.prod_id =  products.prod_id)   ORDER BY promotions.subcategory,products.subcategory

In this example clustering query, the select sub-query of the originalDML statement is included. Thus, the clustering query will select thesame set of source fact table rows that the original DML statement wouldhave selected. The join criteria have been converted to force left outerjoins between the sales fact table and the promotions and productsdimension tables. An order by clause is added to sort the source facttable rows in a linear order by values of the promotions.subcategory andproducts.subcategory columns in accordance with the BY LINEAR ORDERsorting directive in the clustering criteria.

As discussed, the source fact table rows can be sorted in a linear orderor an interleaved order based on a space-filing curve. To do so, thedatabase server may generate a clustering query that invokes theCLUSTERING function in the ORDER BY clause of the clustering query. Forexample, assume that instead of the clustering criteria above specifyingBY LINEAR ORDER, it instead specified BY INTERLEAVED ORDER, then thedatabase server may automatically convert the DML statement into thefollowing clustering query.

INSERT INTO sales SELECT promo_id, prod_id, ... amount_sold FROMsales_external   LEFT OUTER JOIN promotions ON   (sales.promo_id =promotions.promo_id)   LEFT OUTER JOIN products ON (sales.prod_id =  products.prod_id)   ORDER BY ORA_CLUSTERING(promotions.subcategory,  products.subcategory)

This clustering query is similar to the clustering query generated whenBY LINEAR ORDER is specified in the clustering criteria. The differencein this clustering query is that the ORA_CLUSTERING function is invokedin the ORDER BY clause to achieve an interleaved sorting order of thesource fact table rows.

Zonemaps

According to an embodiment of the present invention, I/O pruning duringtable scans is facilitated in a database server through the use ofzonemaps. Generally, a zonemap is a database access structure thatallows a database server to skip a disk scan of certain disk blocks of atable when scanning the table because it is known, based on the zonemap,that the skipped disk blocks cannot contain data relevant to the queryfor which the table scanning is being performed.

At a high level, generating a zonemap for a table involves dividing thedisk blocks of the table into sets of contiguous disk blocks called“zones”. For each zone, the minimum and maximum values of interestingcolumns are determined. According to an embodiment of the presentinvention, the interesting columns can be columns of the table for whichthe zonemap is being generated (e.g., columns of a fact table) orcolumns of other tables (e.g., columns of dimension tables). A table forwhich a zonemap is being generated is referred to hereinafter as a“zoned table”. The “interesting” columns that a zonemap maintainsminimum and maximum values for are referred to hereinafter as the “zonedcolumns” of the zonemap. According to an embodiment of the presentinvention, the zoned columns of a zonemap do not have to be (but can be)columns of the zoned table.

When the database server executes a query that qualifies one of thezoned columns C with a filter predicate having a constant predicatevalue V, the database server can compare the value V to the minimumvalue and the maximum value of the column C determined for a zone todetermine whether the zone can possibly contain data satisfying thefilter predicate. If the zone cannot possibility satisfy any filterpredicate of the query, then the disk blocks of the zone may be skippedduring a table scan of the zoned table.

The filter predicate can be a relational predicate of the form “zonedcolumn C<predicate operator> constant V”, where <predicate operator> isthe equality operator (e.g., “=”), the less than or equal to operator(e.g., “<=”), the less than operator (e.g., “<”), the greater thanoperator (e.g., “>”), the greater than or equal to operator (e.g.,“>=”), or the not equal to operator (e.g., “< >”). Where the predicateoperator is the equality operator, a zone cannot possibility satisfy thefilter predicate if the predicate value V is both less than the minimumvalue of the column C for the zone and greater than the maximum value ofthe column C for the zone. Where the predicate operator is the less thanoperator, the zone cannot possibility satisfy the filter predicate ifthe predicate value V is less than or equal to the minimum value of thecolumn C for the zone. Where the predicate operator is the less than orequal to operator, the zone cannot possibility satisfy the filterpredicate if the predicate value V is less than the minimum value of thecolumn C for the zone. Where the predicate operator is the greater thanoperator, the zone cannot possibility satisfy the filter predicate ifthe predicate value V is greater than or equal to the maximum value ofthe column C for the zone. Where the predicate operator is the greaterthan or equal to operator, the zone cannot possibility satisfy thefilter predicate if the predicate value V is greater than the maximumvalue of the column C for the zone. Where the predicate operator is thenot equal to operator, the zone cannot possibility satisfy the filterpredicate if the minimum value and the maximum value of the column C forthe zone are equal and the predicate value V equals the minimum andmaximum values.

Alternatively, the filter predicate can contain an IN list thatspecifies a list of alternative constant values, for example, “wherecountries.region IN (‘Western Europe’, ‘Eastern Europe’)”. Where thefilter predicate contains an IN list, a zone cannot possibility satisfythe filter predicate if each predicate value V in the IN list is bothless than the minimum value of the column C for the zone and greaterthan the maximum value of the column C for the zone.

As yet another alternative, the filter predicate can contain a LIKEoperator with a constant character string value or a constant characterstring value that prefixes a wildcard operator, for example,“countries.region LIKE ‘Western %’). Where the filter predicate containsa LIKE operator with a constant character string value or a constantcharacter string value that prefixes a wildcard operator, a zone cannotpossibility satisfy the filter predicate if the upper bound on the rangeof character string values covered by the LIKE operator is less than theminimum value of the column C for the zone or if the lower bound on therange of character string values covered by the LIKE operator is greaterthan the maximum value of the column C for the zone. For example, a zonecannot possibility satisfy the “countries.region LIKE ‘Western %’)filter predicate if the upper bound string “Westero” is less than theminimum value of the column C for the zone or if the lower bound string“Western” is greater than the maximum value of the column C for thezone.

A Zonemap Example

As an example of using a zonemap to facilitate I/O pruning in a databaseserver, consider the database table 300 of FIG. 3. The table 300 hasfive columns named order_key, ship_date, receipt_date, destination, andquantity. The table 300 has eight rows labeled 301-308 in FIG. 3. Apractical embodiment may have many more rows numbering in the millions,billions, or more.

Referring now to FIG. 4, it illustrates how the rows 301-308 of table300 may be stored on a portion of a disk 400 in a sorted order in diskblocks 401-404. The disk portion 400 may corresponds to an extent, asegment, a tablespace, or other logical portion of a disk. The diskportion 400 is viewed logically by the database server as a set ofseparately addressable disk blocks arranged in a linear order. The diskblocks of the disk portion 400 are numbered consecutively according totheir linear order by the database server. When rows of a table arestored in a sorted order (e.g., a linear order or an interleaved order)in contiguous disk blocks (e.g., rows 301-308 of table 300 stored indisk blocks 401-404), the rows are said to be “clustered” within thetable. More generally, the table is said to be a “clustered” table.

In this example, rows 301-308 of table 300 are stored in a linear sortorder based on the values of the ship_date column. In particular, rows301 and 302 are stored in disk block 401, rows 303 and 304 are stored indisk block 402, rows 305 and 306 are stored in disk block 403, and rows307 and 308 are stored in disk block 404. A practical embodiment mayhave more or less rows per disk block and/or have a different number ofrows per disk block or have disk blocks within the table that containdifferent numbers of disk blocks. Further, the rows of a table may bestored in many more disk blocks numbering in the tens, hundreds,thousands, millions, or more. Further still, a disk block may store rowsfrom more than one table.

Continuing the illustration of the use of zonemaps for I/O pruning, azonemap for table 300 may be constructed in which each zone consists oftwo disk blocks. The maximum number of disk blocks per zone of a zonemapis referred to herein as the “zonemap scale” of the zonemap. In oneembodiment, the zonemap scale of a zonemap is user-configurable.Generally, a chosen zonemap scale is a tradeoff between minimizing thenumber of zones of the zonemap, where the zonemap scale is relativelylarge, and maximizing I/O pruning efficiency, where the zonemap scale isrelatively small.

In one embodiment, the user specifies a zonemap scaling factor S as aninteger value greater than zero. The database server then computes thezonemap scale as 2^(S) (i.e., two to the power of S, where S>0). Forexample, if the zonemap scaling factor for a zonemap is 10, then thezonemap scale of the zonemap is 1024 disk blocks. Other manners ofspecifying a zonemap scaling factor and calculating the zonemap scaleare possible and the present invention in not limited to any particularmanner. Further, a default zonemap scale for a zonemap may be calculatedby the database server based on a variety of factors including thenumber of rows of the zoned table, the number of disk blocks of thezoned table, and the disk block size.

Returning to the example, FIG. 5 illustrates a zonemap 500 on table 300.The zonemap 500 may be represented as a table and may be stored in adatabase as such. In this example, the zonemap scaling factor is 1 andthe zonemap scale is 2¹ or 2. Consequently, the four disk blocks 401-404of FIG. 4 are divided in two zones 501 and 502 as shown in FIG. 5. Eachzone 501 and 502 contains two contiguous disk blocks. In particular,zone 501 contains contiguous disk blocks 401 and 402 and zone 502contains contiguous disk blocks 403 and 404.

Each row 511 and 512 of zonemap 500 corresponds to a zone 501 and 502 ofthe zonemap. In particular, row 511 corresponds to zone 501 and row 512corresponds to zone 502. The zonemap 500 includes a zone disk blockrange column 513 specifying, for each zone, the first block in the setof contiguous disk blocks covered by the zone. More generally, thecolumn 513 indicates or specifies the range of contiguous disk blockscovered by a zone, for each zone of the zonemap 500. For example,assuming disk blocks 401-404 are consecutively numbered by the databaseserver 1, 2, 3, and 4 respectively, the values in the column 513indicate that zone 501 covers contiguous disk blocks 401 and 402 andthat zone 502 covers contiguous disk blocks 403 and 404. The columns ofthe zonemap 500 also include a minimum value column 514 and a maximumvalue column 515 for each zoned columns on which the zonemap 500 isconstructed.

Based on zonemap 500 and given the following query with a filterpredicate on the ship_date column, a database server performing a fulltable scan of table 300 can skip a scan of disk blocks 3 and 4 becausethose disk blocks, based on the minimum and maximum values stored incolumns 514B and 515B in row 512 of the zonemap 500, cannot contain rowsrelevant to the query. Instead, only a scan of disk blocks 1 and 2 isneeded.

SELECT * FROM lineitem WHERE ship_date=‘01-01-2008’

Dimensional Zonemaps

A “dimensional zonemap” is a zonemap of a clustered fact table based onat least one column of a dimension table. A dimensional zonemap of afact table facilitates I/O pruning of the fact table based on filterpredicates in a query on columns of the dimension tables. According toone embodiment, a dimensional zonemap is created by a “dimensionalzonemap query”. The dimensional zonemap query creates a zonemap in thedatabase in the form of a materialized view. To populate the view, thedimensional zonemap query selects rows from the clustered fact table andjoins them with rows of one or more dimension tables. The join is basedon foreign key columns of the fact table and unique key columns of thedimension tables.

According to an aspect of the present invention, the dimensional zonemapquery groups the selected fact table rows into zones by invoking a “zoneidentifier assignment” function. The zone identifier assignment functionmaps row identifiers of rows selected from the fact table to zones ofthe dimensional zonemap. More specifically, all rows selected from theclustered fact table within the same N contiguous data blocks are mappedto the same zone, where N is based on the zonemap scale of thedimensional zonemap. In addition, the dimensional zonemap querycalculates the minimum value and maximum value for each zone for eachzoned column and stores the calculated values in the materialized view.

For example, consider a sales fact table clustered based on the regionand the subregion columns of a countries dimension table according tothe following clustering criteria specified in the following CREATETABLE DDL statement.

CREATE TABLE sales (   prod_id number not null,   cust_id number notnull, ...   amount_sold number(10,2) ) CLUSTERING   sales JOIN countriesON (sales.country_id = countries.country_id)   BY LINEAR ORDER(countries.region, countries.subregion)   YES ON LOAD YES ON DATAMOVEMENT

To take advantage of the sales fact table clustered based on the aboveclustering criteria, a dimensional zonemap on the sales fact table maybe generated by the following dimensional zonemap query.

CREATE MATERIALIZED ZONEMAP sales_zmap AS SELECTSYS_OP_ZONE_ID(f.rowid),   MIN(c. region), MAX(c.region),  MIN(c.subregion), MAX(c. subregion)   FROM sales f LEFT JOIN countriesc ON (f.country_id =   c.country_id)   GROUP BY SYS_OP_ZONE_ID(f.rowid)

Here, a left outer join between the sales fact table and the countriesdimension table is performed to ensure that all rows selected from thesales fact table for the join are taken into account in the zonemap. TheSYS_OP_ZONE_ID function is the zone identifier assignment function. TheSYS_OP_ZONE_ID function maps the input row identifier to a zoneidentifier. According to the SYS_OP_ZONE_ID, all row identifiersbelonging to a contiguous set of N data blocks of the sales fact tableare mapped to the same zone, where N is the zonemap scale. The GROUP BYsub-clause is used to properly calculate the minimum value and maximumvalue for the two zoned columns (countries.region andcountries.subregion) per zone. The resulting materialized view,sales_zmap, will have five columns, one column storing zone identifiersand two columns for each the two zoned columns storing the minimum andmaximum values calculated per zone.

The column structure of the sales_zmap materialized view is illustratedin FIG. 6. As shown, the materialized view 600 has a column for storingzone identifiers (zone_id) and two columns for each of thecountries.region and countries.subregion columns storing the minimum andmaximum values calculated for the zones. Each row of the view 600corresponds to one zone of the sales_zmap dimensional zonemap.

As mentioned, a dimensional zonemap facilitates scan pruning of a facttable when executing star queries containing filter predicates oncolumns of dimension tables. For example, the sales_zmap dimensionalzonemap can be used by a database server to facilitate I/O pruning whenexecuting the following query.

SELECT country_name, SUM(sales) FROM sales f JOIN countries ON(sales.country_id = countries.country_id) WHEREcountries.region=’Europe’ AND countries.subregion= ’West Europe’ GROUPBY countries.name

Here, the query on the sales fact table contains two filter predicates,one on each of the zoned columns. These are also columns by which thesales fact table has been clustered in an interleaved order according tothe clustering criteria above. Based on this query, a scan of zones forwhich either one of the filter predicate values (i.e., ‘Europe’ or ‘WestEurope’) is not within the ranges set by the minimum and maximum valuesin the dimensional zonemap can be skipped.

If clustering of the fact table is on multiple dimension tables,creation of a dimensional zonemap is analogous to the case whereclustering of the fact table is on a single dimension table. Forexample, if the sales fact table is clustered by countries and productsdimension tables instead of just the countries dimension table as in theexample above, then the following dimensional zonemap query zonemap maybe executed to generate a dimensional zonemap for the sales table.

CREATE MATERIALIZED ZONEMAP sales_zmap AS SELECTSYS_OP_ZONE_ID(f.rowid),      MIN(countries.region),MAX(countries.region),      MIN(countries.subregion),MAX(countries.subregion),      MIN(products.category),MAX(products.category),      MIN(products.subcategory),MAX(products.subcategory) FROM sales f LEFT JOIN countries c ON(f.country_id = c.country_id)      LEFT JOIN products p ON (f.prod_id =p.prod_id) GROUP BY SYS_OP_ZONE_ID(f.rowid)

As with the single dimension case, the dimension zonemap query performsa left outer join between the fact table and each of the dimensiontables. As a result, the rows in the fact table are assigned to zones ofthe zonemap in the order the rows are stored within the fact table(e.g., in the linear or interleaved order determined when the fact tablewas clustered). In particular, the rows of the fact table stored in thefirst N disk blocks of the fact table are assigned to the first zone ofthe zonemap, the rows of the fact table stored in the next N disk blocksof the fact table are assigned to the second zone of the zonemap, and soon, where N is the zonemap scale.

Creating a Dimensional Zonemap

As mentioned, a dimensional zonemap for a fact table may be created witha dimensional zonemap query. Internally, the zonemap may be implementedby the database server as a materialized view. According to oneembodiment of the present invention, the dimensional zonemap query is aDDL statement beginning with the keywords “CREATE MATERIALIZED ZONEMAP”.Examples of CREATE MATERIALIZED ZONEMAP DDL statement are provided inthis description according to a particular syntax. Of course, othersyntaxes may be used to convey the same semantics.

A dimensional zonemap query for creating a dimensional zonemap has anumber of characteristics. For one, a dimensional zonemap query mayreference a fact table and one or more dimension tables, with eachdimension table left outer joined to the fact table. That is, the facttable is on the left of every join to a dimension table in thedimensional zonemap query. This ensures that all rows of the fact tableare considered in the zonemap. Second, a dimensional zonemap querycontains a select sub-query. The select sub-query contains a singleinvocation of the zone identifier assignment function, along with pairsof minimum and maximum function invocations on columns of the fact tableand/or columns of the dimension tables. Third, a dimensional zonemapquery contains a GROUP BY clause containing a single invocation of thezone identifier assignment function. The zone identifier assignmentfunction is implemented by the database server and accepts, as input, anidentifier of a row in the fact and returns, as output, an identifier ofa zone of the dimensional zonemap to which the input fact table is rowis assigned. The assignment is based on the disk blocks of the facttable in which the row is stored and the zonemap scale of thedimensional zonemap. An example of a dimensional zonemap query is:

CREATE MATERIALIZED ZONEMAP sales_zmap AS SELECTSYS_OP_ZONE_ID(f.rowid),    MIN(countries.region),MAX(countries.region),    MIN(countries.subregion),MAX(countries.subregion),    MIN(products.category),MAX(products.category),    MIN(products.subcategory),MAX(products.subcategory) FROM sales f LEFT JOIN countries c ON(f.country_id = c.country_id)       LEFT JOIN products p ON (f.prod_id =p.prod_id) GROUP BY SYS_OP_ZONE_ID(f.rowid)

According to one embodiment, the zonemap scaling factor of thedimensional zonemap may be specified in a dimensional zonemap query. Forexample, in the following dimensional zonemap query a zonemap scalingfactor of 8 is specified. Consequently, each zone of the dimensionalzonemap will span at most 2⁸ or 256 disk blocks. In the absence of anexplicit zonemap scaling factor, the database server may use a defaultzonemap scaling factor.

CREATE MATERIALIZED ZONEMAP sales_zmap SCALE 8 AS SELECT SYS_OP_ZONE_ID(f.rowid),    MIN(countries.region), MAX(countries.region),   MIN(countries.subregion), MAX(countries.subregion),   MIN(products.category), MAX(products.category),   MIN(products.subcategory), MAX(products.subcategory) FROM sales fJOIN countries c ON (f.country_id = c.country_id)    JOIN products p ON(f.prod_id = p.prod_id) GROUP BY SYS_OP_ZONE_ID(f.rowid)

In another embodiment, a dimensional zonemap query is automaticallygenerated and executed by the database server in response to a DDLstatement specifying clustering criteria that contains, as a sub-clauseof the clustering directive, a directive to create a dimensionalzonemap. In one embodiment, the clustering criteria directive to createa dimensional zonemap based on clustering criteria contains the keywords‘WITH MATERIALIZED ZONEMAP’. For example, the following DDL statementwith clustering criteria creates a ‘sales’ fact table and clusters the‘sales’ fact table according to a linear sort order based on values inthe ‘countries.region’ and ‘countries.subregion’ columns of the‘countries’ dimension table. The clustering criteria also specifies thata dimension zonemap should be created when clustering the ‘sales’ facttable.

CREATE TABLE sales (   prod_id number not null,   cust_id number notnull, ...   amount_sold number(10,2) ) CLUSTERING   sales JOIN countriesON (sales.country_id =   countries.country_id)   BY LINEAR ORDER(countries.region, countries.subregion)   YES ON LOAD YES ON DATAMOVEMENT   WITH MATERIALIZED ZONEMAP (sales_zmap)

In response to the above DDL statement, after the ‘sales’ fact table hasbeen clustered according to the clustering criteria specified in the DDLstatement, the database server may create the following dimensionalzonemap query to create the requested zonemap:

CREATE MATERIALIZED ZONEMAP sales_zmap AS SELECTSYS_OP_ZONE_ID(sales.rowid), MIN(countries.region),MAX(countries.region), MIN(countries.subregion),MAX(countries.subregion) FROM sales LEFT JOIN countries ON(sales.country_id = countries.country_id) GROUP BYSYS_OP_ZONE_ID(sales.rowid)

Scan Pruning

According to one embodiment of the present invention, a dimensionalzonemap of a fact table is used by a database server during a table scanof the fact table. The dimensional zonemap is used by the databaseserver for I/O pruning. In particular, the database server uses thedimensional zonemap to skip entire zones of disk blocks during the tablescan. Since the zoned columns of the dimensional zonemap may be columnsof the dimension tables, scan pruning based on filter predicates on thedimension tables in a star query is possible.

FIG. 7 is a flowchart of a disk scan 700 of a fact table using adimensional zonemap, according to an embodiment of the presentinvention. The scan 700 may be performed by a database server in thecontext of executing a star query or other query against the fact tablethat contains filter predicates on one or more zoned columns of thedimensional zonemap.

The query may contain filter predicates on just the fact table, just oneor more dimension tables, or on both the fact table and one or moredimension tables. The zoned columns may be just columns of the facttable, just columns of one or more dimension tables, or columns fromboth the fact table and one or more dimension tables.

The zoned columns may be a variety of different data types includingnumeric, timestamp, row identifier, float, double, and character datatypes. As discussed above, a filter predicate on a zoned column in thequery can: (1) be a relational predicate of the form “zoned columnC<predicate operator> constant V”, where <predicate operator> is theequality operator (e.g., “=”), the less than or equal to operator (e.g.,“<=”), the less than operator (e.g., “<”), the greater than operator(e.g., “>”), the greater than or equal to operator (e.g., “>=”), or thenot equal to operator (e.g., “< >”), (2) contain an IN list thatspecifies a list of alternative constant values, for example, “wherecountries.region IN (‘Western Europe’, ‘Eastern Europe’)”, or (3)contain a LIKE operator with a constant character string value or aconstant character string value that prefixes a wildcard operator, forexample, “countries.region LIKE ‘Western %’).

The query may combine filter predicates, including filter predicates oncolumns other than zoned columns, with conjunctions, disjunctions, or amix of conjunctions and disjunctions into an expression whichcorresponds to the WHERE clause of the query. Depending on theconstruction of the WHERE clause expression in terms of conjunctions anddisjunctions, if all of one or more of all the filter predicates onzoned columns in the expression are not satisfied, then the expressionas a whole may not be able to be satisfied. For example, if either ofthe two filter predicates in the expression “WHEREcountries.region=‘Europe’ AND countries.subregion=‘West Europe’ is notsatisfied, then the expression as a whole cannot be satisfied. Asanother example, if both of the filter predicates in the expression“WHERE countries.region=‘Europe’ OR countries.subregion=‘West Europe’”are not satisfied, then the expression as a whole cannot be satisfied bythat row.

A minimum set of filter predicates on zoned columns in a WHERE clauseexpression of a query that, if any are not satisfied, means that theexpression as a whole cannot be satisfied is referred to hereinafter asa set of “pruning” filter predicates of the query. The set of pruningfilter predicates of a query may be a strict subset of all filterpredicates on zoned columns in the query when the WHERE clauseexpression combines filter predicates in the conjunctive. Thedimensional zonemap may be used for I/O pruning during the scan 700 ofthe fact table when the query against the fact table has a non-empty setof pruning filter predicates. If the query has an empty set of pruningfilter predicates, then the dimensional zonemap cannot provide I/Opruning benefits for that query. The following description of the scan700 of FIG. 7 assumes that the query executing against the fact tablehas a non-empty set of pruning filter predicates.

Initially, the scan 700 begins (block 701) at an initial disk block ofthe fact table. The initial disk block may be the first disk block ofthe fact table, or subsequent disk block of the fact table correspondingto a first row identifier in a specified range of row identifiers of thefact table to scan. Recall that the disk blocks of the fact table areconsecutively numbered. Thus, there is a sequential order to the diskblocks that make up the fact table.

Next, the zone of the dimensional zonemap containing the initial diskblock is determined (block 702). Generally, this involves mapping thedisk block number of the initial disk block to a zone of the dimensionalzonemap that covers a range of disk blocks that includes the initialdisk block. For this purpose, the database server may maintain a mappingbetween disk block numbers of zone identifiers. As one example of apossible mapping, the dimensional zonemap may have a unique key columnthat stores the number of the first disk block in each zone of thedimensional zonemap.

As an example of a possible mapping between disk block numbers and zonesof the dimensional zonemap, FIG. 8 illustrates the column structure of adimensional zonemap 800 having a column 813 storing starting disk blocknumbers for zones of the dimensional zonemap 800. In particular,according to the dimensional zonemap 800, the zone with zone identifier1 starts at disk block number 1 and the zone with zone identifier 2starts at disk block number 3. Since disk block numbers are sequential,if the values of the starting disk block number column are taken inorder, then the values of the starting disk numbers form ranges of diskblocks covered by the zones of the dimensional zonemap. Further, thezonemap scale of a dimensional zonemap is established when thedimensional zonemap is created. Thus, the zonemap scale of thedimensional zonemap is known at the time of the scan 700. For example,the zonemap scale of the dimensional zonemap 800 is two (2). Thus, indimensional zonemap 800, zone 1 covers disk blocks 1 through 2 and zone2 covers disk blocks 3 through 4.

The remaining steps 703-709 of the scan 700 represents an iteration overa list of zones of the dimensional zonemap starting at the first zonedetermined in step 702 and proceeding to the last zone in the list. Theorder of the zones in the list corresponds to the order of the diskblocks covered by the zones on disk. Thus, the iteration over the listof zones from the first zone to the last zone represents a sequentialscan of the fact table starting from the initial disk block of the firstzone to the last disk block of the last zone. Some of the zones in thelist may be skipped depending on the minimum and maximum values storedin the dimensional zonemap. At step 703, the iteration starts with acurrent zone variable being set to the first zone.

At step 704, a check is made to determine whether current zone variablerefers to a zone of the dimensional zonemap. The current zone variablemay not refer to a zone of the dimensional zonemap if the initial diskblock is not within any zone of the zonemap. In this case, a full scanof the fact table starting at the initial disk block is performed (block705). The current zone variable may also not refer to a zone of thedimensional zonemap after step 709, if the last zone in the list ofzones has been processed. In this case, the scan 700 ends if there areno more disk blocks of the fact table to scan, or the scan 700 continuesfrom the first disk block after the last disk block of the last zone.

If the current zone variable refers to a zone of the dimensionalzonemap, then, at step 705, the database server determines whether ascan of the current zone can be skipped. This determination is madebased on a set of one or more pruning filter predicates of the query andthe minimum and maximum values for the zoned columns, as recorded forthe current zone in the dimensional zonemap. In particular, for a givenpruning filter predicate in the set, the predicate value or values ofthe pruning filter predicate are compared to the minimum and/or maximumvalue for the zoned column of the pruning filter predicate, as recordedfor the zone in the dimensional zonemap. The comparison is performed todetermine whether the current zone can possibly contain rows of the facttable that satisfy the pruning filter predicate. Specifically, if thepruning filter predicate specifies a zoned column of a dimension table,then the comparison is performed to determine whether the current zonecan possibly contain rows of the fact table that, if joined with thedimension table, satisfy the pruning filter predicate. If the pruningfilter predicate specifies a zoned column of the fact table, then thecomparison is performed to determine whether the current zone canpossible contain rows of the fact table that satisfy the pruning filterpredicate. Thus, the zoned columns of the dimensional zonemap are notlimited to only columns of the fact table but can include columns ofdimension tables or be exclusively columns of the dimension tables. Ifany one of the pruning filter predicates in the set cannot possibly besatisfied by the rows of the current zone, then the scan 700 can skip adisk scan of the disk blocks of the current zone. If each and everypruning filter predicates in the set can possibly be satisfied by therows of the current zone, then the scan 700 cannot skip the current zoneand a disk scan of the disk blocks of the current zone is performed.

When comparing the predicate value or values of the pruning filterpredicate to the minimum and/or maximum value for the zoned column ofthe pruning filter predicate, as recorded for the zone in thedimensional zonemap, the comparison performed depends on the type ofpruning filter predicate. In general, the pruning filter predicate canbe one of three different types: (1) the pruning filter predicate can bea relational predicate of the form “zoned column C<predicate operator>constant V”, (2) the pruning filter predicate can contain an IN listthat specifies a list of alternative constant values, or (3) the pruningfilter predicate can contain a LIKE operator with a constant characterstring value or a constant character string value that prefixes awildcard operator.

Where the pruning filter predicate is a relational predicate, the<predicate operator> can be the equality operator (e.g., “=”), the lessthan or equal to operator (e.g., “<=”), the less than operator (e.g.,“<”), the greater than operator (e.g., “>”), the greater than or equalto operator (e.g., “>=”), or the not equal to operator (e.g., “< >”).Where the predicate operator is the equality operator, the current zonecannot possibility satisfy the pruning filter predicate if the predicatevalue V is both less than the minimum value of the column C for thecurrent zone and greater than the maximum value of the column C for thecurrent zone. Where the predicate operator is the less than operator,the current zone cannot possibility satisfy the pruning filter predicateif the predicate value V is less than or equal to the minimum value ofthe column C for the current zone. Where the predicate operator is theless than or equal to operator, the current zone cannot possibilitysatisfy the pruning filter predicate if the predicate value V is lessthan the minimum value of the column C for the current zone. Where thepredicate operator is the greater than operator, the current zone cannotpossibility satisfy the pruning filter predicate if the predicate valueV is greater than or equal to the maximum value of the column C for thecurrent zone. Where the predicate operator is the greater than or equalto operator, the current zone cannot possibility satisfy the pruningfilter predicate if the predicate value V is greater than the maximumvalue of the column C for the current zone. Where the predicate operatoris the not equal to operator, the current zone cannot possibilitysatisfy the pruning filter predicate if the minimum value and themaximum value of the column C for the current zone are equal and thepredicate value V equals the minimum and maximum values of the column Cfor the current zone.

Alternatively, the pruning filter predicate can contain an IN list thatspecifies a list of alternative constant values, for example, “wherecountries.region IN (‘Western Europe’, ‘Eastern Europe’)”. Where thepruning filter predicate contains an IN list, the current zone cannotpossibility satisfy the pruning filter predicate if each predicate valueV in the IN list is both less than the minimum value of the column C forthe current zone and greater than the maximum value of the column C forthe current zone.

As yet another alternative, the pruning filter predicate can contain aLIKE operator with a constant character string value or a constantcharacter string value that prefixes a wildcard operator, for example,“countries.region LIKE ‘Western’), “countries.region LIKE ‘Western %’),“countries.region LIKE ‘Western % abc’), or “countries.region LIKE‘Western % abc % def’). In these examples, the string “Western” is aconstant character string value and the ‘%’ character is a wildcardoperator. Where the pruning filter predicate contains a LIKE operatorwith a constant character string value or a constant character stringvalue prefixing a wildcard operator, the current zone cannot possibilitysatisfy the pruning filter predicate if the upper bound on the range ofcharacter string values covered by the LIKE operator is less than theminimum value of the column C for the current zone or if the lower boundon the range of character string values covered by the LIKE operator isgreater than the maximum value of the column C for the current zone. Forexample, the current zone cannot possibility satisfy the“countries.region LIKE ‘Western %’) pruning filter predicate if theupper bound string “Westero” is less than the minimum value of thecolumn C for the current zone or if the lower bound string “Western” isgreater than the maximum value of the column C for the current zone.

If each and every pruning filter predicate in the set of pruning filterpredicates in the query can possibly be satisfied by the current zone,then a disk scan of the disk blocks of the current zone is performed(step 707). If the current zone is the first zone, then the scan of thecurrent zone starts at the initial disk block and proceeds to the lastdisk block of the first zone. Since the zones cover contiguous sets ofdisk blocks and the disk blocks are consecutively numbered, the lastdisk block of the first zone can be determined from the number of thefirst disk block of the next zone in the list of zones. If the currentzone is not the first zone, then the scan of the current zone starts atthe first disk block of the current zone and proceeds to the last diskblock of the current zone. Alternatively, if no pruning filter predicatein the query can be satisfied by the current zone, then a scan of thecurrent zone is skipped and the scan proceeds to step 708.

At step 708, the next zone after the current zone in the list of zonesis determined. At step 709, the current zone variable is set to the nextzone and the scan 700 returns to step 704 to consider the new currentzone.

Zonemap Driven Scan

The approach of FIG. 7 for I/O pruning is driven by a scan of the facttable starting an initial disk block. As zones are encountered duringthe scan of the fact table, the dimensional zonemap is consulted todetermine which zones can be skipped. As alternative to scan driven I/Opruning, a zonemap driven scan of the fact table is also possible. Underthis alternative approach, the dimensional zonemap is consulted priorito initiating the scan to determine which zones of the dimensionalzonemap could possibly satisfy at least one of the pruning filterpredicates in the query. This consultation results in ranges ofcontiguous disk blocks that need to be scanned. The scan is thenperformed on only these zones and the other zones that could notpossibility satisfy any of the pruning filter predicates are notscanned.

Hardware Overview

According to one embodiment, the techniques described herein areimplemented by one or more special-purpose computing devices. Thespecial-purpose computing devices may be hard-wired to perform thetechniques, or may include digital electronic devices such as one ormore application-specific integrated circuits (ASICs) or fieldprogrammable gate arrays (FPGAs) that are persistently programmed toperform the techniques, or may include one or more general purposehardware processors programmed to perform the techniques pursuant toprogram instructions in firmware, memory, other storage, or acombination. Such special-purpose computing devices may also combinecustom hard-wired logic, ASICs, or FPGAs with custom programming toaccomplish the techniques. The special-purpose computing devices may bedesktop computer systems, portable computer systems, handheld devices,networking devices or any other device that incorporates hard-wiredand/or program logic to implement the techniques.

For example, FIG. 9 is a block diagram that illustrates a computersystem 900 upon which an embodiment of the invention may be implemented.Computer system 900 includes a bus 902 or other communication mechanismfor communicating information, and a hardware processor 904 coupled withbus 902 for processing information. Hardware processor 904 may be, forexample, a general purpose microprocessor.

Computer system 900 also includes a main memory 906, such as a randomaccess memory (RAM) or other dynamic storage device, coupled to bus 902for storing information and instructions to be executed by processor904. Main memory 906 also may be used for storing temporary variables orother intermediate information during execution of instructions to beexecuted by processor 904. Such instructions, when stored innon-transitory storage media accessible to processor 904, rendercomputer system 900 into a special-purpose machine that is customized toperform the operations specified in the instructions.

Computer system 900 further includes a read only memory (ROM) 908 orother static storage device coupled to bus 902 for storing staticinformation and instructions for processor 904. A storage device 910,such as a magnetic disk, optical disk, or solid-state drive is providedand coupled to bus 902 for storing information and instructions.

Computer system 900 may be coupled via bus 902 to a display 912, such asa cathode ray tube (CRT), for displaying information to a computer user.An input device 914, including alphanumeric and other keys, is coupledto bus 902 for communicating information and command selections toprocessor 904. Another type of user input device is cursor control 916,such as a mouse, a trackball, or cursor direction keys for communicatingdirection information and command selections to processor 904 and forcontrolling cursor movement on display 912. This input device typicallyhas two degrees of freedom in two axes, a first axis (e.g., x) and asecond axis (e.g., y), that allows the device to specify positions in aplane.

Computer system 900 may implement the techniques described herein usingcustomized hard-wired logic, one or more ASICs or FPGAs, firmware and/orprogram logic which in combination with the computer system causes orprograms computer system 900 to be a special-purpose machine. Accordingto one embodiment, the techniques herein are performed by computersystem 900 in response to processor 904 executing one or more sequencesof one or more instructions contained in main memory 906. Suchinstructions may be read into main memory 906 from another storagemedium, such as storage device 910. Execution of the sequences ofinstructions contained in main memory 906 causes processor 904 toperform the process steps described herein. In alternative embodiments,hard-wired circuitry may be used in place of or in combination withsoftware instructions.

The term “storage media” as used herein refers to any non-transitorymedia that store data and/or instructions that cause a machine tooperate in a specific fashion. Such storage media may comprisenon-volatile media and/or volatile media. Non-volatile media includes,for example, optical disks, magnetic disks, or solid-state drives, suchas storage device 910. Volatile media includes dynamic memory, such asmain memory 906. Common forms of storage media include, for example, afloppy disk, a flexible disk, hard disk, solid-state drive, magnetictape, or any other magnetic data storage medium, a CD-ROM, any otheroptical data storage medium, any physical medium with patterns of holes,a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip orcartridge.

Storage media is distinct from but may be used in conjunction withtransmission media. Transmission media participates in transferringinformation between storage media. For example, transmission mediaincludes coaxial cables, copper wire and fiber optics, including thewires that comprise bus 902. Transmission media can also take the formof acoustic or light waves, such as those generated during radio-waveand infra-red data communications.

Various forms of media may be involved in carrying one or more sequencesof one or more instructions to processor 904 for execution. For example,the instructions may initially be carried on a magnetic disk orsolid-state drive of a remote computer. The remote computer can load theinstructions into its dynamic memory and send the instructions over atelephone line using a modem. A modem local to computer system 900 canreceive the data on the telephone line and use an infra-red transmitterto convert the data to an infra-red signal. An infra-red detector canreceive the data carried in the infra-red signal and appropriatecircuitry can place the data on bus 902. Bus 902 carries the data tomain memory 906, from which processor 904 retrieves and executes theinstructions. The instructions received by main memory 906 mayoptionally be stored on storage device 910 either before or afterexecution by processor 904.

Computer system 900 also includes a communication interface 918 coupledto bus 902. Communication interface 918 provides a two-way datacommunication coupling to a network link 920 that is connected to alocal network 922. For example, communication interface 918 may be anintegrated services digital network (ISDN) card, cable modem, satellitemodem, or a modem to provide a data communication connection to acorresponding type of telephone line. As another example, communicationinterface 918 may be a local area network (LAN) card to provide a datacommunication connection to a compatible LAN. Wireless links may also beimplemented. In any such implementation, communication interface 918sends and receives electrical, electromagnetic or optical signals thatcarry digital data streams representing various types of information.

Network link 920 typically provides data communication through one ormore networks to other data devices. For example, network link 920 mayprovide a connection through local network 922 to a host computer 924 orto data equipment operated by an Internet Service Provider (ISP) 926.ISP 926 in turn provides data communication services through the worldwide packet data communication network now commonly referred to as the“Internet” 928. Local network 922 and Internet 928 both use electrical,electromagnetic or optical signals that carry digital data streams. Thesignals through the various networks and the signals on network link 920and through communication interface 918, which carry the digital data toand from computer system 900, are example forms of transmission media.

Computer system 900 can send messages and receive data, includingprogram code, through the network(s), network link 920 and communicationinterface 918. In the Internet example, a server 930 might transmit arequested code for an application program through Internet 928, ISP 926,local network 922 and communication interface 918.

The received code may be executed by processor 904 as it is received,and/or stored in storage device 910, or other non-volatile storage forlater execution.

In the foregoing specification, embodiments of the invention have beendescribed with reference to numerous specific details that may vary fromimplementation to implementation. The specification and drawings are,accordingly, to be regarded in an illustrative rather than a restrictivesense. The sole and exclusive indicator of the scope of the invention,and what is intended by the applicants to be the scope of the invention,is the literal and equivalent scope of the set of claims that issue fromthis application, in the specific form in which such claims issue,including any subsequent correction.

1. A method for pruning disk blocks of a target table in a relationaldatabase management system, the method comprising: dividing the diskblocks of the target table into a plurality of zones; maintaining, foreach zone of the plurality of zones, a minimum column value and amaximum column value for each of one or more zoned columns of one ormore zoned tables; wherein at least one of the one or more zoned tablesis not the target table; receiving a query on the target table; whereinthe query contains a filter predicate on a particular column of the oneor more zoned columns; wherein the filter predicate has a predicatevalue; in response to receiving the query, determining, based on thepredicate value and minimum column values and the maximum column valuesmaintained for the particular column, zero or more zones of theplurality of zones that cannot possibly contain rows of the target tablesatisfying the filter predicate; and determining, based on the zero ormore zones of the plurality of zones that cannot possibly contain rowsof the target table satisfying the filter predicate, whether a disk scanof the zero or more zones is necessary; wherein the method is performedby one or more computing devices.
 2. The method of claim 1, wherein theparticular column is not a column of the target table.
 3. The method ofclaim 1, wherein none of the one or more zoned columns is a column ofthe target table.
 4. The method of claim 1, wherein the target table isa fact table of a star schema and the particular column is a column of adimension table of the star schema.
 5. The method of claim 1, furthercomprising: in response to receiving the query, determining, based onthe predicate value and minimum column values and maximum column valuesmaintained for the particular column, one or more zones of the pluralityof zones that cannot possibly contain rows of the target tablesatisfying the filter predicate; and determining, based on the one ormore zones of the plurality of zones that cannot possibly contain rowsof the target table satisfying the filter predicate, one or moreparticular zones, of the one or more zones of the plurality of zonesthat cannot possibly contain rows of the target table satisfying thefilter predicate, for which a disk scan is not necessary; and returningan answer to the query without performing a disk scan of the one or moreparticular zones.
 6. The method of claim 1, wherein the particularcolumn is not a column of the target table, and wherein dividing thedisk blocks of the target table into a plurality of zones includes:performing a left outer join between the target table and the tablehaving the particular column to produce a set of joined rows, eachjoined row of the set of joined rows corresponding to one row of thetarget table; and for each joined row in the set of joined rows,assigning the corresponding row of the target table to one zone of theplurality of zones.
 7. The method of claim 1, wherein each zone of theplurality of zones includes at most a predetermined number of contiguousdisk blocks.
 8. The method of claim 1, wherein maintaining, for eachzone of the plurality of zones, a minimum column value and a maximumcolumn value for each of the one or more zoned columns includesmaintaining a materialized view in a database, the materialized viewincluding one row for each zone of the plurality of zones, one columnfor each of the one or more zoned columns storing the minimum columnvalues for the zoned column, and one column for each of the one or morecolumns storing the maximum column values for the zoned column.
 9. Themethod of claim 1, wherein the filter predicate contains a LIKE operatorand the predicate value has a constant character string value or aconstant character string value prefixing a wildcard operator.
 10. Themethod of claim 1, wherein the particular column is not a column of thetarget table, and wherein the query contains join criteria, the joincriteria specifying a join between the target table and the table havingthe particular column, the join criteria further specifying that thejoin is to be based on a foreign key column of the target table and aunique key column of the table having the particular column.
 11. Themethod of claim 1, wherein the particular column has a database datatype; and wherein the database data type is selected from the groupconsisting of numeric, character, date, timestamp, row identifier,float, and double.
 12. One or more non-transitory computer-readablemedia storing instructions which, when executed by one or moreprocessors, cause performance of a method for pruning disk blocks of atarget table in a relational database management system, the methodcomprising: dividing the disk blocks of the target table into aplurality of zones; maintaining, for each zone of the plurality ofzones, a minimum column value and a maximum column value for each of oneor more zoned columns of one or more zoned tables; wherein at least oneof the one or more zoned tables is not the target table; receiving aquery on the target table; wherein the query contains a filter predicateon a particular column of the one or more zoned columns; wherein thefilter predicate has a predicate value; in response to receiving thequery, determining, based on the predicate value and minimum columnvalues and the maximum column values maintained for the particularcolumn, zero or more zones of the plurality of zones that cannotpossibly contain rows of the target table satisfying the filterpredicate; and determining, based on the zero or more zones of theplurality of zones that cannot possibly contain rows of the target tablesatisfying the filter predicate, whether a disk scan of the zero or morezones is necessary; wherein the method is performed by one or morecomputing devices.
 13. The one or more non-transitory computer-readablemedia of claim 12, wherein the particular column is not a column of thetarget table.
 14. The one or more non-transitory computer-readable mediaof claim 12, wherein none of the one or more zoned columns is a columnof the target table.
 15. The one or more non-transitorycomputer-readable media of claim 12, wherein the target table is a facttable of a star schema and the particular column is a column of adimension table of the star schema.
 16. The one or more non-transitorycomputer-readable media of claim 12, further comprising: in response toreceiving the query, determining, based on the predicate value andminimum column values and maximum column values maintained for theparticular column, one or more zones of the plurality of zones thatcannot possibly contain rows of the target table satisfying the filterpredicate; and determining, based on the one or more zones of theplurality of zones that cannot possibly contain rows of the target tablesatisfying the filter predicate, one or more particular zones, of theone or more zones of the plurality of zones that cannot possibly containrows of the target table satisfying the filter predicate, for which adisk scan is not necessary; and returning an answer to the query withoutperforming a disk scan of the one or more particular zones.
 17. The oneor more non-transitory computer-readable media of claim 12, wherein theparticular column is not a column of the target table, and whereindividing the disk blocks of the target table into a plurality of zonesincludes: performing a left outer join between the target table and thetable having the particular column to produce a set of joined rows, eachjoined row of the set of joined rows corresponding to one row of thetarget table; and for each joined row in the set of joined rows,assigning the corresponding row of the target table to one zone of theplurality of zones.
 18. The one or more non-transitory computer-readablemedia of claim 12, wherein each zone of the plurality of zones includesat most a predetermined number of contiguous disk blocks.
 19. The one ormore non-transitory computer-readable media of claim 12, whereinmaintaining, for each zone of the plurality of zones, a minimum columnvalue and a maximum column value for each of the one or more zonedcolumns includes maintaining a materialized view in a database, thematerialized view including one row for each zone of the plurality ofzones, one column for each of the one or more zoned columns storing theminimum column values for the zoned column, and one column for each ofthe one or more columns storing the maximum column values for the zonedcolumn.
 20. The one or more non-transitory computer-readable media ofclaim 12, wherein the filter predicate contains a LIKE operator and thepredicate value has a constant character string value or a constantcharacter string value prefixing a wildcard operator.
 21. The one ormore non-transitory computer-readable media of claim 12, wherein theparticular column is not a column of the target table, and wherein thequery contains join criteria, the join criteria specifying a joinbetween the target table and the table having the particular column, thejoin criteria further specifying that the join is to be based on aforeign key column of the target table and a unique key column of thetable having the particular column.
 22. The one or more non-transitorycomputer-readable media of claim 1, wherein the particular column has adatabase data type; and wherein the database data type is selected fromthe group consisting of numeric, character, date, timestamp, rowidentifier, float, and double.